<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/20 0020
 * Time: 下午 6:48
 */
namespace app\common\command;

use app\common\redis\Redis;

class Supervision{
    public static function cron(){
        self::sendsms();
    }
    private static function sendsms(){
        $Redis = Redis::getRedisConn();
        $smsObj = new \app\lib\Sms();
        $meetingdata = $Redis->LRange('supervision_mobile_list',0,-1);
        if($meetingdata){
            foreach ($meetingdata as $v){
                $v = json_decode($v,true);
                if(!empty($v)){
                    $message = '';
                    $message .= "督办业务提醒：\n督办主题：" . $v['title'] . "\n";
                    $message .= '督办时间：' . substr($v['complete_time'],0,10) . "之前完成\n";
                    $message .= '紧急程度：' . $v['urgency_degree'] . "\n";
                    $message .= '请尽快办理，务必按时完成 【江陵住建】';
                    $smsRes = $smsObj->sendMsg($v['p_phone'], $message);
                    if (isset($smsRes)) {
                        if ($smsRes['msg'] == 'ok') {
                            $Redis->LRem('supervision_mobile_list',json_encode($v),-1);
                        } else {
                            trace($v . ' 短信发送失败','notice');
                        }
                    }
                }

            }
        }
    }
}